<template>
	<view v-for="(item, index) in list" class="list" :key="index">
		<view class="badge" v-if="item.state == 0"></view>
		<view>
			<image class="msgImage" src="http://112.124.50.179:8888/imgs/home/tixing.png"></image>
		</view>
		<view class="list_right1">
			<view class="title">
				<view>{{ item.title }}</view>
				<view class="time">{{ formatTimestamp(item.createdAt) }}</view>
			</view>
			<view class="txt" v-html="formattedText(item.content)"></view>
		</view>
	</view>
</template>

<script setup>
import { defineProps } from 'vue';
import { formatTimestamp } from '@/utils/time.js';
let props = defineProps(['list']);

const formattedText = (rawText) => {
	return rawText.replace(/\n/g, '<br>');
};
</script>

<style lang="scss">
.list {
	background-color: #292b2a;
	border-radius: 10rpx;
	display: flex;
	padding: 32rpx;
	margin-bottom: 24rpx;
	position: relative;
}

.badge {
	position: absolute;
	width: 20rpx;
	height: 20rpx;
	background-color: #ff4c5a;
	border-radius: 50%;
	right: 0rpx;
	top: 0rpx;
}

.msgImage {
	width: 88rpx;
	height: 88rpx;
	margin-right: 24rpx;
	border-radius: 50%;
}

.list_right1 {
	width: 100%;
	display: flex;
	flex-direction: column;

	.title {
		font-size: 32rpx;
		color: #fff;
		margin-bottom: 16rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.time {
			font-size: 24rpx;
			white-space: nowrap;
		}
	}

	.txt {
		font-size: 24rpx;
		color: #c5c5c5;
		line-height: 40rpx;
	}
}
</style>
